<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
	xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout">
<head th:include="inc/home::header">
</head>
<link type="text/css" th:href="@{/css/content.css}" rel="stylesheet" />
<body>
	<!--返回-->
	<div class="back" onclick="loadPage('/data-clean')">
		<img src="images/back.png" />
	</div>
	<div class="head-top">
		<div th:include="header :: header"></div>
	</div>
	<div class="header-title">
		<span>数据库操作</span>
	</div>
	<div class="spare-a">
		<div class="save-bg">
			<a href="javascript:void(0)" class="spare-tj" onClick="Save()">确定</a>
		</div>
		<div class="spare-add">
			<ul>
				<li>
					<div class="spare-addl">文件：</div>
					<div class="spare-addr">
						<form name="form" method="post" action="">
							<input type="text" name="uploadfile" id="uploadfile" class="spare-add-input" />
							<input type="button" name="submit" value="浏览"
								onClick="this.form.file.click();" class="uploadfile"  accept="*.sql"/> <input
								type="file" name="file" id="file" style="display: none;"
								onChange="this.form.uploadfile.value=this.value;" />
						</form>
					</div>
				</li>
			</ul>
		</div>
	</div>
</body>
<script th:inline="javascript">
	/*<![CDATA[*/
	function verifyNull(obj) {

		if (obj == null || obj.val() == "" || obj.val() == "请选择") {
			top.$
					.Zebra_Dialog(
							'<div class="prompt"><div class="warning-icon"></div><div class="success-title">输入的内容不能包含空</div></div>',
							{
								'title' : '提示',
								'buttons' : [ '确定' ]
							});
			return false;
		}
		return true;
	}
	function getData() {
		if (!verifyNull($("#file"))) {
			return false;
		}
		return true;
	}
	function Save() {
		var validate = getData();
		if (!validate) {
			return false;
		}
		var path=$("#uploadfile").val();
		if(path==null&path=="")
		{
			alert("请选择一个.sql文件");
		}
		else
		{
			$.post("/restore",{path:path},function(data){
				if(data=="success")
				{
					alert("成功恢复数据");
				}
			});
		}
        
		

	}

	/*]]>*/
</script>
</html>
